package com.tobestronger.shouxiespringframework.core.convert;

import com.sun.istack.internal.Nullable;

/**
 * 类型转换服务 抽象接口
 */
public interface ConversionService {

    /**
     * 是否可以实现从 sourceType 到 targetType 的转换 <br/>
     * Return {@code true} if objects of {@code sourceType} can be converted to the {@code targetType}.
     */
    boolean canConvert(@Nullable Class<?> sourceType, Class<?> targetType);

    /**
     * 实现从 sourceType 到 targetType 的转换 <br/>
     *  Convert the given {@code source} to the specified {@code targetType}.
     */
    <T> T convert(Object source, Class<T> targetType);

}
